package com.gmm.springboot.admin.service.test02.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gmm.springboot.admin.mapper.test02.LoginRecord;
import com.gmm.springboot.admin.mapper.test02.LoginRecordMapper;
import com.gmm.springboot.admin.service.test02.LoginRecordService;

@Service
public class LoginRecordServiceImpl implements LoginRecordService {
	@Autowired
	private LoginRecordMapper loginRecordMapper;

	public void addRecord(LoginRecord record) {
		if (record == null) {
			return;
		}

		Date now = new Date();

		loginRecordMapper.addRecord(record);
	}

	public List<LoginRecord> findRecordsByMap(Map<String, Object> whereParams, int beginIndex, int maxCount) {
		if (whereParams == null) {
			whereParams = new HashMap<String, Object>(0);
		}

		whereParams.put("beginIndex", beginIndex);
		whereParams.put("maxCount", maxCount);

		return loginRecordMapper.findSelectRecordByMap(whereParams);
	}

	public void updateRecord(LoginRecord record) {
		if (record == null) {
			return;
		}

		Date now = new Date();

		loginRecordMapper.updRecord(record);
	}

	public void deleteRecord(Long id) {
		if (id == null) {
			return;
		}

		loginRecordMapper.delRecord(id);
	}

	public int findRecordCount(Map<String, Object> whereParams) {
		return loginRecordMapper.findRecordsCount(whereParams);
	}

	public LoginRecord findRecordByKey(Long id) {
		if (id == null) {
			return null;
		}

		return loginRecordMapper.findRecordByKey(id);
	}

}
